import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'
import { Account } from '../stores/account.store'

@Component({
  selector: 'app-balance',
  changeDetection: ChangeDetectionStrategy.OnPush,
  templateUrl: './balance.component.html',
  styleUrls: [ './balance.component.css' ]
})
export class BalanceComponent implements OnInit {

  constructor(public account: Account) {
  }

  ngOnInit() {
  }

  doSomething() {
    const money = Math.ceil(Math.random() * 100)
    if (Math.random() >= 0.5) {
      this.account.deposite(money)
      console.log('deposite', money)
    } else {
      this.account.withdraw(money)
      console.log('withdraw', money)
    }
  }
}
